21. Casting with findViewById

Casting with findViewById

Question:

Start Quiz:

Solution:

INSTRUCTOR NOTE:

Another video on findViewById from the “Developing Android Apps” Udacity course.

Learn more about casting in Java (see “Casting Objects” section)

Update: Starting at API 26, Android Oreo, the manual casting for the findViewById() method is no longer required in your code. The quiz was created prior to API 26 so the cast is still required when answering the quiz questions. The findViewById method is now able to dynamically infer and return the right type of the View.

Note: There is a typo in this solution video. For #4, it should say findViewById not findViewByid.